import 'package:flutter/cupertino.dart';

import '../../../pojo/ImPojo.dart';
import '../../../util/ImConstant.dart';

class MessagePaneBackgroundView extends StatelessWidget {

  final Widget child;
  final ImMessage message;

  const MessagePaneBackgroundView({ required this.child, required this.message, super.key});

  @override
  Widget build(BuildContext context) {
    var isSender = message.currentUserId == message.fromUserId;
    var backgroundColor = isSender ? ImConstant.MESSAGE_SEND_COLOR : ImConstant.MESSAGE_RECEIVE_COLOR;
    if (message.messageType == ImMessageType.Chat) {
      backgroundColor = message.messageType != ImMessageType.Chat ? ImConstant.IM_RESERVE_BACKGROUND_COLOR :
      ImConstant.MESSAGE_SEND_COLOR;
    }

    return Container(
      padding: const EdgeInsets.only(top: 10, right: 10, bottom: 10, left: 10),
      decoration: ShapeDecoration(
        color: backgroundColor,
        shape: const RoundedRectangleBorder(side: BorderSide.none, borderRadius: BorderRadius.all(Radius.circular(5))),
      ),
      child: child,
    );
  }
}